project(demo)
cmake_minimum_required(VERSION 2.8)
message("Project Directory: ${PROJECT_SOURCE_DIR}")

set(CMAKE_MACOSX_RPATH 1)
#set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Release")
include_directories(header)
include_directories(common/header)

set(CMAKE_C_FLAGS "-std=gnu99")
set(CMAKE_CXX_FLAGS "-std=c++11")

add_definitions(-D USE_SYSCTYPE)
add_definitions(-D __linux__)
add_definitions(-D SETTARGET_DEVICE_GENERIC_LINUX)
add_definitions(-D SETTARGET_DEBUG_ENABLED=0)

set(ARCH "AMD64" CACHE STRING "Target Arch")
IF (ARCH STREQUAL "ARM")
  include_directories(/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/arm-fsl-linux-gnueabi/include)
  set(CMAKE_C_COMPILER "/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-gcc")
  set(CMAKE_CXX_COMPILER "/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-g++")
ELSE (ARCH STREQUAL "AMD64")
  include_directories(/usr/include/x86_64-linux-gnu)
  set(CMAKE_C_COMPILER "gcc")
  set(CMAKE_CXX_COMPILER "g++")
  LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/linux_x64)
ENDIF (ARCH STREQUAL "ARM")

link_directories(${PROJECT_SOURCE_DIR}/lib)

add_executable(example-server exampleApplications/examples/source/IEC61850Functions.c
                      exampleApplications/examples/source/LocalData.c
                      exampleApplications/examples/source/MainServer.c
                      exampleApplications/examples/source/PIS10CreateServerClient.c
                      exampleApplications/examples/source/PIS10Callbacks.c
                      exampleApplications/examples/source/PrintView.c
                      exampleApplications/examples/source/UserInput.c)
target_link_libraries(example-server yxpis pthread rt)
target_include_directories(example-server PUBLIC exampleApplications/examples/header)

add_executable(example-client exampleApplications/examples/source/IEC61850Functions.c
                      exampleApplications/examples/source/LocalData.c
                      exampleApplications/examples/source/MainClient.c
                      exampleApplications/examples/source/PIS10CreateServerClient.c
                      exampleApplications/examples/source/PIS10Callbacks.c
                      exampleApplications/examples/source/PrintView.c
                      exampleApplications/examples/source/UserInput.c)
target_link_libraries(example-client yxpis pthread rt)
target_include_directories(example-client PUBLIC exampleApplications/examples/header)
